home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Utilities / Programming / EnterAct 3.5 / Drag_on Modules / hAWK programs / $XRef_Full < prev    next >
Encoding:
Text File  |  1993-04-09  |  4.3 KB  |  147 lines  |  [TEXT/KEEN]

  1. # $XRef_Full: from one or more source files, build a cross-reference list
  2. #of all top-level terms. The built-in function "lookup" must be
  3. #supported by the application calling hAWK (at present this means just
  4. #EnterAct).  For this to work properly when called from EnterAct, you
  5. #must have a project open, the project must include files which define
  6. #all the terms you wish to cross-reference (include the toolbox headers
  7. #in your project if you want toolbox terms cross-referenced), and your
  8. #dictionary should be up to date.
  9. #Similar to $XRef, but does not skip over comments and strings, so
  10. #"spurious" references may result. Presumably, you'll want them.
  11. #Use "Set variables" when calling this program to specify which kinds
  12. #of terms to include in the cross-reference. There are eight kinds of
  13. #terms, and eight corresponding variables that can be set to 0 or 1,
  14. #eg do_defines=0 means don't include defines, whereas do_defines=1 means
  15. #include defines.
  16. #
  17. #Typically use the “MFS selected files” input option on one or more files.
  18. #Any other input option is also OK, just ensure an appropriate EnterAct
  19. #project is open before running this program.
  20. #
  21. #The array "skipList" (see "XRef_Full.T") holds a list of common terms to skip over.
  22. #In large cross-reference jobs it may be NECESSARY to skip the commonest
  23. #terms to avoid overflowing the list of references. 
  24.  
  25. # User’s Manual references:
  26. # «hAWK User’s Manual» «F   Running hAWK programs»
  27. # «hAWK User’s Manual» «L  5   Regular expressions»
  28. # «hAWK User’s Manual» «M  5   Built-in string and file functions»
  29. # «hAWK User’s Manual» «K  4   Built-in variables»
  30. # «hAWK User’s Manual» «K  8   Arrays»
  31. # «hAWK User’s Manual» «N   User-defined functions»
  32. # «hAWK User’s Manual» «P  3   The getline function»
  33. # «hAWK User’s Manual» «O  3   Output into files»
  34. # «hAWK User’s Manual» «Q   The hAWK function»
  35.  
  36. BEGIN {
  37.     if (do_defines == 0 && do_variables == 0 && do_functions == 0 &&
  38.         do_enumConsts == 0 && do_typedefs == 0 && do_structs == 0 &&
  39.         do_unions == 0 && do_enums == 0)
  40.         {
  41.         print "Please use the Set variables button"
  42.         print "and select which kinds of term to reference."
  43.         print "Currently all the selector variables are zero."
  44.         exit
  45.         }
  46.     #Generate the actual xref program from the template program
  47.     #First, a couple of arrays to simplify things
  48.     if (do_defines != 0)
  49.         {
  50.         numfor["defines"] = 1
  51.         namefor["defines"] = ": #define"
  52.         }
  53.     if (do_variables != 0)
  54.         {
  55.         numfor["vars"] = 2
  56.         namefor["vars"] = ": variable"
  57.         }
  58.     if (do_functions != 0)
  59.         {
  60.         numfor["funcs"] = 4
  61.         namefor["funcs"] = ": function"
  62.         }
  63.     if (do_enumConsts != 0)
  64.         {
  65.         numfor["enumCs"] = 8
  66.         namefor["enumCs"] = ": enum constant"
  67.         }
  68.     if (do_typedefs != 0)
  69.         {
  70.         numfor["typedefs"] = 16
  71.         namefor["typedefs"] = ": typedef"
  72.         }
  73.     if (do_structs != 0)
  74.         {
  75.         numfor["structs"] = 32
  76.         namefor["structs"] = ": struct tag"
  77.         }
  78.     if (do_unions != 0)
  79.         {
  80.         numfor["unions"] = 64
  81.         namefor["unions"] = ": union tag"
  82.         }
  83.     if (do_enums != 0)
  84.         {
  85.         numfor["enums"] = 128
  86.         namefor["enums"] = ": enum tag"
  87.         }
  88.     templateFile = STDPATH "Drag_on Modules:hAWK programs:" "XRef_Full.T"
  89.     actualFile = STDPATH "Drag_on Modules:hAWK programs:" "XRef_Full.A"
  90.     while (getline < templateFile > 0)
  91.         {
  92.         if (match($0, /##MARK record/))
  93.             {
  94.             ++tLines
  95.             for (i in numfor)
  96.                 {
  97.                 if (doneIf)
  98.                     print "\t\telse if (type == " numfor[i] ") #" namefor[i] > actualFile
  99.                 else#First one, omit the else
  100.                     print "\t\tif (type == " numfor[i] ") #" namefor[i] > actualFile
  101.                 #print defines[$i] = defines[$i] "\t" fIndex "\t" FNR
  102.                 print "\t\t\t" i "[$i] = " i "[$i] \"\\t\" fIndex \"\\t\" FNR" > actualFile
  103.                 doneIf = 1
  104.                 }
  105.             }
  106.         else if (match($0, /##MARK linear/))
  107.             {
  108.             ++tLines
  109.             for (i in numfor)
  110.                 {
  111.                 print "\tfor (w in " i ")" > actualFile
  112.                 print "\t\t{" > actualFile
  113.                 print "\t\tlinear[++m] = w \"" namefor[i] "\" " i "[w]" > actualFile
  114.                 print "\t\tdelete " i "[w]" > actualFile
  115.                 print "\t\t}" > actualFile
  116.                 }
  117.             }
  118.         else
  119.             print > actualFile
  120.         }
  121.     if (tLines < 2)#template missing or damaged
  122.         {
  123.         print "The template file"
  124.         print templateFile
  125.         if (!tLines)
  126.             print "is damaged or missing."
  127.         else
  128.             print "is damaged."
  129.         exit
  130.         }
  131.     else
  132.         {
  133.         close(templateFile)
  134.         close(actualFile)
  135.         }
  136.     #TEST
  137.     ##exit
  138.     #Execute the new specific program XRef_Full.A
  139.     argv[x++] = "hAWK"
  140.     argv[x++] = "-f" actualFile
  141.     argv[x++] = "--"
  142.     for (i = 1; i < ARGC; ++i)
  143.         argv[x++] = ARGV[i]
  144.     hAWK(argv)
  145.     }
  146.  
  147.